import urllib
import urllib2
import json

server = 'http://api.xiaonei.com/restserver.do'
url = server;

parms={
"api_key":"9efcae555af746f58d14e7e8df5e310d",
"method":"xiaonei.feed.publishTemplatizedAction",
"v":"1.0",

"session_key":"2.60ff18001c29283f46e87b6ac0515342.3600.1240347600-913635539",
"template_id":"1",


}
parms = urllib.urlencode(parms)
data = urllib2.urlopen(url,parms).read()
print data.decode('utf8')
'''
#print 'request:',url
#print 'response:',data
u1 = json.read(data)['sessionID']
print u1

url = server+'/addChat?sessionID='+u1+"&content=abc"
data = urllib2.urlopen(url).read();
print 'request:',url
print 'response:',data

#user 2 login:
url = server+'/login'
data = urllib2.urlopen(url).read()
print 'request:',url
print 'response:',data
u2 = json.read(data)['sessionID']
print u2

url = server+'/getNotification?sessionID='+u2
data = urllib2.urlopen(url).read()
print 'request:',url
print 'response:',data
#user2 send
url = server+'/addChat?sessionID='+u2+"&content=def"
data = urllib2.urlopen(url).read();
print 'request:',url
print 'response:',data
#user2 send
url = server+'/addChat?sessionID='+u2+"&content=ghi"
data = urllib2.urlopen(url).read();
print 'request:',url
print 'response:',data


#user 3 login
url = server+'/login'
data = urllib2.urlopen(url).read()
print 'request:',url
print 'response:',data

u3 = json.read(data)['sessionID']
print u3

url = server+'/getNotification?sessionID='+u3
data = urllib2.urlopen(url).read()
print 'request:',url
print 'response:',data

'''